<?php use_helper('Date'); ?>
<?php use_helper('jQuery'); ?>
<?php 
	use_helper('sdInteractiveChart'); 
	addInteractiveChartJavascript();
?>

<h1>Tableau de bord</h1>

<table class="detail">
	<!-- caractéristiques du projet-->
	<tr>
		<th>Début</th>
		<td><?php echo ($projet->getPrjDateDebut() <> '0000-00-00' ? format_date($projet->getPrjDateDebut(), 'dd/MM/yyyy') : '') ?></td>
	</tr>
	<tr>
		<th>Fin</th>
		<td><?php echo ($projet->getPrjDateFin() <> '0000-00-00' ? format_date($projet->getPrjDateFin(), 'dd/MM/yyyy') : '') ?></td>
	</tr>
</table>


<div class="action">
<?php echo link_to('Modifier', 'projet/edit?prj_id='.$projet->getPrjId(), array('class' => 'action')) ?>
<?php
	if (count($projet->getTaches()) == 0) {
		echo ' &nbsp ';
		echo link_to('Supprimer', 'projet/delete?prj_id='.$projet->getPrjId(), array('method' => 'delete', 'confirm' => 'Etes-vous sûr ?', 'class' => 'action'));
	}
?>
</div>


<div class="section">
<h2>Alertes</h2>

<table>
	<?php foreach ($alerte_list as $alerte): ?>
	<tr class="alerte">
		<td><?php echo link_to(image_tag('coche.png'), 'calendrier/ok?cal_id='.$alerte->getCalId()) .'&nbsp;' ?></td>
		<td><?php echo format_date($alerte->getCalDate(), 'dd/MM/yyyy') ?></td>
		<td class="alerte"><?php echo $alerte->getCalLibelle() ?></td>
		<td><?php echo $alerte->getCalDescription() ?></td>
	</tr>
	<?php endforeach; ?>
</table>
</div>



<div class="section">
<h2>Tâches</h2>

<ul class="no-style">
	<li>Tâches en cours : 
	<?php 
		$nbTachesEnCours = $projet->getNbTachesEnCours(); 
		echo $nbTachesEnCours; 
		if ($nbTachesEnCours > 0) {
			echo ' &nbsp; <label id="label_taches_en_cours" onClick="div_show(\'taches_en_cours\');">[+]</label>';
		}
	?>
	</li>
	
	<?php
		if ($nbTachesEnCours > 0) {
			echo '<div id="taches_en_cours" class="hidden">';
			echo '<ul class="no-style">';
			foreach ($projet->getTachesEnCours() as $tache) {
				echo '<li>'. link_to(image_tag('show.png'), 'tache/show?tac_id='.$tache->getTacId()) .' &nbsp '. $tache->getTacLibelle() .'</li>';
			}
			echo '</ul>';
			echo '</div>';
		}
	?>
	
	<li>Tâches en retard : 
	<?php 
		$nbTachesEnRetard = $projet->getNbTachesEnRetard(); 
		echo '<span '. ($nbTachesEnRetard > 0 ? 'class="alerte"' : '') .'>';
		echo $nbTachesEnRetard; 
		echo '</span>';
		if ($nbTachesEnRetard > 0) {
			echo ' &nbsp; <label id="label_taches_en_retard" onClick="div_show(\'taches_en_retard\');">[+]</label>';
		}
	?>
	</li>
	
	<?php
		if ($nbTachesEnRetard > 0) {
			echo '<div id="taches_en_retard" class="hidden">';
			echo '<ul class="no-style">';
			foreach ($projet->getTachesEnRetard() as $tache) {
				echo '<li>'. link_to(image_tag('show.png'), 'tache/show?tac_id='.$tache->getTacId()) .' &nbsp '. $tache->getTacLibelle() .'</li>';
			}
			echo '</ul>';
			echo '</div>';
		}
	?>
</ul>


<?php
/*
$chart = InteractiveChart::newPieChart();
$chart->setWidthAndHeight('300', '200');
$chart->setOption('title', 'Nb tâches par état');
$chart->setPieSliceText(PieGraph::$PIE_TEXT_VALUE);
$chart->ajaxGraph(url_for('projet/loadStatsEtatTaches?prj_id='.$projet->getPrjId()), array(), 'chart_div');
$chart->render();
*/
?>
<?php
/*
$chart = InteractiveChart::newPieChart();
$chart->setWidthAndHeight('300', '200');
$chart->setOption('title', 'Nb tâches en dépassement');
$chart->setPieSliceText(PieGraph::$PIE_TEXT_VALUE);
$chart->ajaxGraph(url_for('projet/loadStatsDepassementTaches?prj_id='.$projet->getPrjId()), array(), 'chart_div2');
$chart->render();
*/
?>

<div id="chart_div" class="inline"></div>
<div id="chart_div2" class="inline"></div>
</div>
